package com.asset.dispoal.dic;

import com.asset.dispoal.dic.api.GbDicService;
import com.asset.dispoal.dic.dto.GbDicRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @author qr
 * @date 2022/2/24$
 */
@RestController
@Api(value = "字典配置", tags = "字典配置")
@RequestMapping("sys/gbDic")
public class GbDicController {

    @Autowired
    GbDicService gbDicService;

    @Permission(code = "dictionaries:add")
    @PostMapping("insert")
    @ApiOperation(value = "添加字典", notes = "添加字典")
    public Result insert(@RequestBody GbDicRequest gbDicRequest) {
        gbDicService.insert(gbDicRequest);
        return Result.ok();
    }

    @Permission(code = "dictionaries:del")
    @PostMapping("delete")
    @ApiOperation(value = "删除字典", notes = "删除字典")
    public Result delete(@RequestBody String id) {
        gbDicService.delete(id);
        return Result.ok();
    }

    @Permission(code = "dictionaries:update")
    @PostMapping("update")
    @ApiOperation(value = "修改字典", notes = "修改字典")
    public Result update(@RequestBody GbDicRequest gbDicRequest) {
        gbDicService.update(gbDicRequest);
        return Result.ok();
    }

    @Permission(code = "dictionaries", param = "t.create_user_id")
    @PostMapping("queryPage")
    @ApiOperation(value = "分页查询字典", notes = "分页查询字典")
    public Result<PageVO> queryPage(@RequestBody GbDicRequest GbDicRequest) {
        return gbDicService.queryPage(GbDicRequest);
    }
}
